package com.zmn.plat.admin.controller.standard.record;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.alibaba.dubbo.config.annotation.Reference;
import com.zmn.common.constant.GlobalConsts;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.manager.common.database.annotation.ReadOnlyConnection;
import com.zmn.mcc.common.constant.DpermitConsts;
import com.zmn.mcc.common.dto.dept.DeptDRO;
import com.zmn.mcc.dubbo.interfaces.dept.DeptListRemoteService;
import com.zmn.plat.admin.controller.PlatBaseController;
import com.zmn.plat.business.interfaces.standard.StandardRecordBService;
import com.zmn.plat.dubbo.utils.DubboConsts;
import com.zmn.plat.services.interfaces.standard.read.StandardReadService;
import com.zmn.plat.services.interfaces.standard.read.permission.StandardReadPermissionService;
import com.zmn.plat.services.interfaces.standard.record.StandardRecordService;

/**
 * 标准列表
 *
 * @author linfeng
 * @since 2020-02-12 10:23:38
 */
public class StandardRecordBaseController extends PlatBaseController {
    protected Logger logger = LoggerFactory.getLogger(this.getClass());
    @Resource
    protected StandardRecordService standardRecordService;

    @Resource
    protected StandardReadPermissionService standardReadPermissionService;

    @Resource
    protected StandardReadService standardReadService;

    @Resource
    protected StandardRecordBService standardRecordBService;

    @Reference(version = DubboConsts.INTERFACE_VERSION, check = false)
    DeptListRemoteService deptListRemoteService;

    /**
     * 获取一级部门
     *
     * @return the one dept list
     */
    @ReadOnlyConnection
    protected List<DeptDRO> getOneDeptList() {
        ResponseDTO<List<DeptDRO>> data = deptListRemoteService.listDeptByLevelAndStatus(DpermitConsts.DEPT_LEVEL_ONE, GlobalConsts.YES);
        List<DeptDRO> oneDeptList = new ArrayList<>();
        if (data.isSuccess()) {
            oneDeptList = data.getData();
        }

        return oneDeptList;
    }

    /**
     * 获取二级部门
     *
     * @return the two dept list
     */
    @ReadOnlyConnection
    protected List<DeptDRO> getTwoDeptList() {
        ResponseDTO<List<DeptDRO>> data = deptListRemoteService.listDeptByLevelAndStatus(DpermitConsts.DEPT_LEVEL_TWO, GlobalConsts.YES);
        List<DeptDRO> twoDeptList = new ArrayList<>();
        if (data.isSuccess()) {
            twoDeptList = data.getData();
        }

        return twoDeptList;
    }
}
